package org.openspaces.example.helloworld.common;

import org.openspaces.core.GigaSpace;

public class Car extends AbstractCar{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2383271927506640410L;
	GigaSpace gigaSpace;
	StructureTuple struc;
	int xTile;
	int yTile;
	int xRoxel;
	int yRoxel;
	Direction dir;
	public Direction getDir() {
		return dir;
	}


	public void setDir(Direction dir) {
		this.dir = dir;
	}




	Roxel roxel;
	private Integer id = null;
	static int idCnt = 1;
	


	public Car() {
		super();
		id = idCnt++;
		// TODO Auto-generated constructor stub
	}


	public Car(Direction dir) {
		super();
		id = idCnt++;
		this.dir = dir;

	}

	public Car(int xTile, int yTile, int xRoxel, int yRoxel) {
		super();
		this.xTile = xTile;
		this.yTile = yTile;
		this.xRoxel = xRoxel;
		this.yRoxel = yRoxel;
	}




	public Integer getId() {
		return id;
	}




	public void setId(Integer id) {
		this.id = id;
	}




	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}




	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Car other = (Car) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}




	@Override
	public String toString() {
		return "Car [id=" + id + "]";
	}
	
	

	


//	@Override
//	public void run() {
//        // connect to the space using its URL
//        IJSpace space = new UrlSpaceConfigurer("jini://*/*/processorSpace").space();
//        // use gigaspace wrapper to for simpler API
//         gigaSpace = new GigaSpaceConfigurer(space).gigaSpace();
//        
//        
//        Roxel template = new Roxel();
//        template.setId(null);
//        template.setX(xRoxel);
//        template.setY(yRoxel);
//        template.setCompoundId(xTile, yTile);
//        
//        roxel = gigaSpace.take(template);
//        struc = gigaSpace.read(new StructureTuple());
//        
//	}

}
